package com.luoying.itew.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.luoying.itew.R;
import com.luoying.itew.event.SelectLogEvent;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/5/26.
 * time 2018-5-10
 * author zm
 */
public class LogSelectItemView extends RelativeLayout {

    private static final String TAG = "LogSelectItemView";


    @BindView(R.id.tv_select_itemview)
    TextView tvSelectItemview;
    @BindView(R.id.rl_log_select_name)
    RelativeLayout rlLogSelectName;
    @BindView(R.id.cb_select_itemview)
    CheckBox cbSelectItemview;
    @BindView(R.id.rl_log_select_base)
    RelativeLayout rlLogSelectBase;
    private String Type;

    public LogSelectItemView(Context context) {
        this(context, null);
    }

    public LogSelectItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        View.inflate(getContext(), R.layout.log_select_itemview, this);
        ButterKnife.bind(this, this);
    }

    public void setText(String s, String type) {
        tvSelectItemview.setText(s);
        Type = type;
    }


    @OnClick(R.id.cb_select_itemview)
    public void onViewClicked() {
        boolean checked = cbSelectItemview.isChecked();
        String name = tvSelectItemview.getText().toString();
        EventBus.getDefault().post(new SelectLogEvent(name,Type,checked));
    }
}
